package com.example.healkep.utils;

import android.annotation.SuppressLint;

import java.text.ParseException;
import java.text.SimpleDateFormat;

public class GetWeek {
    public static long week(String date){//date:"yyyy-MM-dd"
        @SuppressLint("SimpleDateFormat") SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String date2 = sDateFormat.format(new java.util.Date());
        String date1 = date;
        long week = 0;
        try {
            long from = sDateFormat.parse(date1).getTime();
            long to = sDateFormat.parse(date2).getTime();
            week =((to - from) / (1000 * 3600 * 24 * 7) + 1);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return week;
    }
}
